#!/bin/bash
# Puppy's simple Yelp replacement for gnome help
# peebee 08-oct-2017

export TEXTDOMAIN=yelp
export OUTPUT_CHARSET=UTF-8
TITLE="Yelp"

caller=$1

SPLASH1=$(gettext "Not Online - Help Not Available")
SPLASH2=$(gettext "Unknown help request from $1 ?")
SPLASH3=$(gettext "Help is loading - please wait...")

OnLine=`find /sys/class/net/ -maxdepth 1 -mindepth 1 ! -name "*lo*" -exec sh -c 'cat "$0"/carrier 2>&1' {} \; | grep 1`
[ "$OnLine" != "1" ] && OnLine=""

if ! [ $OnLine ]; then gtkdialog-splash -timeout 6 -bg red -fg white -text "$SPLASH1"; exit; fi

case "$caller" in
ghelp:gnumeric) webghelp="http://help.gnome.org/users/gnumeric/stable/gnumeric.html";;
ghelp:gparted) webghelp="https://gparted.org/display-doc.php?name=help-manual";;
ghelp:*) webghelp="http://help.gnome.org/users";;
*) gtkdialog-splash -timeout 6 -bg yellow -text "$SPLASH2" ; exit;;
esac

gtkdialog-splash -timeout 3 -bg yellow -text "$SPLASH3"
defaultbrowser $webghelp
